import {sendMessageWithMobileOrEmail, checkMessageIsRight} from '@/api/commons/commons'

const actions = {
  //给手机或者邮箱发送短信验证码
  //fun(state,value)
  sendMessageWithMobileOrEmail({commit, state}, params) {
    const {token, identify} = params
    return new Promise((resolve, reject) => {
      sendMessageWithMobileOrEmail(token, identify).then(resp => {
        resolve(resp);
      }).catch(err => {
        reject(err);
      })
    })
  },

  //检查验证码是否正确
  checkMessageIsRight({commit,state},params){
    const {token, code} = params
    return new Promise((resolve, reject) => {
      checkMessageIsRight(token, code).then(resp => {
        resolve(resp);
      }).catch(err => {
        reject(err);
      })
    })
  }
}

export default {
  namespaced: true,
  actions
}
